//
//  ShowCardTableViewCell.m
//  QRMaster
//
//  Created by myApple on 15/6/5.
//  Copyright (c) 2015年 myApple. All rights reserved.
//

#import "ShowCardTableViewCell.h"

@interface ShowCardTableViewCell()
{
    UIImageView * cardImgView;
    UILabel * roomNameLabel;
    UILabel * addressNameLabel;
    UIImageView * faveImgView;
}

@end


@implementation ShowCardTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self prepareView];
    }
    return self;
}


-(void)prepareView
{
    float ScreenWidth = [UIScreen mainScreen].bounds.size.width;
    float x = 15;
    float y = 5;
    float width = 40;
    float height = 50;
    
    cardImgView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];
    [self.contentView addSubview:cardImgView];
    
    x += width + 30;
    width = ScreenWidth - x;
    height = 15;
    roomNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, height)];
    roomNameLabel.font = [UIFont boldSystemFontOfSize:14.0];
    [self.contentView addSubview:roomNameLabel];
    
    
    y += height + 5;
    height = 15;
    addressNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, height)];
    addressNameLabel.font = [UIFont systemFontOfSize:14.0];
    addressNameLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:addressNameLabel];
    
    x = ScreenWidth - 60;
    width = 20;
    height = 30;
    y = 15;
    faveImgView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];
    [self.contentView addSubview:faveImgView];
    faveImgView.userInteractionEnabled = YES;
    
    UITapGestureRecognizer * faveImgTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(faveImgClick)];
    [faveImgView addGestureRecognizer:faveImgTap];
}

-(void)faveImgClick
{
    
}

-(void)setOccupation:(NSString *)occupation
{
    if ([occupation isEqualToString:@"0"]) {
        cardImgView.image = [UIImage imageNamed:@"房间2"];
    }
    else
    {
        cardImgView.image = [UIImage imageNamed:@"200房卡有人入住2"];
    }
}

-(void)setRoomName:(NSString *)roomName
{
    _roomName = roomName;
    roomNameLabel.text = roomName;
}

-(void)setCommunityName:(NSString *)communityName
{
    _communityName = communityName;
}

-(void)setFloorName:(NSString *)floorName
{
    _floorName = floorName;
    addressNameLabel.text = [NSString stringWithFormat:@"%@ %@ %@",_communityName,_bulidingName,_floorName];
}

-(void)setBulidingName:(NSString *)bulidingName
{
    _bulidingName = bulidingName;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
